﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SCI_actuator
{
    public partial class Mutliservo4 : Form
    {
        private menu_control frmain;
        private xmlrw scixml;
        public Mutliservo4(menu_control fr)
        {
            InitializeComponent();
            this.frmain = fr;
            scixml = new xmlrw();
        }

        private void single_send11_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num1.Text + "04" + "02" + constant.BRAKE + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num1.Text + "04" + "02" + constant.BRAKE + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send21_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num2.Text + "04" + "02" + constant.BRAKE + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num2.Text + "04" + "02" + constant.BRAKE + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send31_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num3.Text + "04" + "02" + constant.BRAKE + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num3.Text + "04" + "02" + constant.BRAKE + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send41_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num4.Text + "04" + "02" + constant.BRAKE + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num4.Text + "04" + "02" + constant.BRAKE + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send51_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num5.Text + "04" + "02" + constant.BRAKE + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num5.Text + "04" + "02" + constant.BRAKE + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send61_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num6.Text + "04" + "02" + constant.BRAKE + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num6.Text + "04" + "02" + constant.BRAKE + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send71_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num7.Text + "04" + "02" + constant.BRAKE + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num7.Text + "04" + "02" + constant.BRAKE + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send81_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num8.Text + "04" + "02" + constant.BRAKE + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num8.Text + "04" + "02" + constant.BRAKE + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send12_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num1.Text + "04" + "02" + constant.REG_ACTION + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num1.Text + "04" + "02" + constant.REG_ACTION + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send22_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num2.Text + "04" + "02" + constant.REG_ACTION + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num2.Text + "04" + "02" + constant.REG_ACTION + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send32_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num3.Text + "04" + "02" + constant.REG_ACTION + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num3.Text + "04" + "02" + constant.REG_ACTION + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send42_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num4.Text + "04" + "02" + constant.REG_ACTION + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num4.Text + "04" + "02" + constant.REG_ACTION + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send52_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num5.Text + "04" + "02" + constant.REG_ACTION + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num5.Text + "04" + "02" + constant.REG_ACTION + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send62_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num6.Text + "04" + "02" + constant.REG_ACTION + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num6.Text + "04" + "02" + constant.REG_ACTION + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send72_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num7.Text + "04" + "02" + constant.REG_ACTION + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num7.Text + "04" + "02" + constant.REG_ACTION + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send82_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num8.Text + "04" + "02" + constant.REG_ACTION + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num8.Text + "04" + "02" + constant.REG_ACTION + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send13_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num1.Text + "04" + "02" + constant.REG_MODEL + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num1.Text + "04" + "02" + constant.REG_MODEL + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send23_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num2.Text + "04" + "02" + constant.REG_MODEL + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num2.Text + "04" + "02" + constant.REG_MODEL + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send33_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num3.Text + "04" + "02" + constant.REG_MODEL + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num3.Text + "04" + "02" + constant.REG_MODEL + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send43_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num4.Text + "04" + "02" + constant.REG_MODEL + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num4.Text + "04" + "02" + constant.REG_MODEL + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send53_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num5.Text + "04" + "02" + constant.REG_MODEL + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num5.Text + "04" + "02" + constant.REG_MODEL + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send63_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num6.Text + "04" + "02" + constant.REG_MODEL + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num6.Text + "04" + "02" + constant.REG_MODEL + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send73_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num7.Text + "04" + "02" + constant.REG_MODEL + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num7.Text + "04" + "02" + constant.REG_MODEL + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send83_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num8.Text + "04" + "02" + constant.REG_MODEL + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num8.Text + "04" + "02" + constant.REG_MODEL + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send14_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num1.Text + "04" + "02" + constant.REG_MODEL + "02");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num1.Text + "04" + "02" + constant.REG_MODEL + "02" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send24_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num2.Text + "04" + "02" + constant.REG_MODEL + "02");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num2.Text + "04" + "02" + constant.REG_MODEL + "02" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send34_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num3.Text + "04" + "02" + constant.REG_MODEL + "02");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num3.Text + "04" + "02" + constant.REG_MODEL + "02" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send44_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num4.Text + "04" + "02" + constant.REG_MODEL + "02");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num4.Text + "04" + "02" + constant.REG_MODEL + "02" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send54_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num5.Text + "04" + "02" + constant.REG_MODEL + "02");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num5.Text + "04" + "02" + constant.REG_MODEL + "02" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send64_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num6.Text + "04" + "02" + constant.REG_MODEL + "02");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num6.Text + "04" + "02" + constant.REG_MODEL + "02" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send74_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num7.Text + "04" + "02" + constant.REG_MODEL + "02");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num7.Text + "04" + "02" + constant.REG_MODEL + "02" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void single_send84_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray(servo_num8.Text + "04" + "02" + constant.REG_MODEL + "02");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + servo_num8.Text + "04" + "02" + constant.REG_MODEL + "02" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void multi_brake_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray("FE" + "21" + servo_num1.Text + "02" + constant.BRAKE + "01"
                + servo_num2.Text + "02" + constant.BRAKE + "01"
                + servo_num3.Text + "02" + constant.BRAKE + "01"
                + servo_num4.Text + "02" + constant.BRAKE + "01"
                + servo_num5.Text + "02" + constant.BRAKE + "01"
                + servo_num6.Text + "02" + constant.BRAKE + "01"
                + servo_num7.Text + "02" + constant.BRAKE + "01"
                + servo_num8.Text + "02" + constant.BRAKE + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + "FE" + "21" + servo_num1.Text + "02" + constant.BRAKE + "01"
                + servo_num2.Text + "02" + constant.BRAKE + "01"
                + servo_num3.Text + "02" + constant.BRAKE + "01"
                + servo_num4.Text + "02" + constant.BRAKE + "01"
                + servo_num5.Text + "02" + constant.BRAKE + "01"
                + servo_num6.Text + "02" + constant.BRAKE + "01"
                + servo_num7.Text + "02" + constant.BRAKE + "01"
                + servo_num8.Text + "02" + constant.BRAKE + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void mutli_run_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray("FE" + "21" + servo_num1.Text + "02" + constant.REG_ACTION + "01"
                + servo_num2.Text + "02" + constant.REG_ACTION + "01"
                + servo_num3.Text + "02" + constant.REG_ACTION + "01"
                + servo_num4.Text + "02" + constant.REG_ACTION + "01"
                + servo_num5.Text + "02" + constant.REG_ACTION + "01"
                + servo_num6.Text + "02" + constant.REG_ACTION + "01"
                + servo_num7.Text + "02" + constant.REG_ACTION + "01"
                + servo_num8.Text + "02" + constant.REG_ACTION + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + "FE" + "21" + servo_num1.Text + "02" + constant.REG_ACTION + "01"
                + servo_num2.Text + "02" + constant.REG_ACTION + "01"
                + servo_num3.Text + "02" + constant.REG_ACTION + "01"
                + servo_num4.Text + "02" + constant.REG_ACTION + "01"
                + servo_num5.Text + "02" + constant.REG_ACTION + "01"
                + servo_num6.Text + "02" + constant.REG_ACTION + "01"
                + servo_num7.Text + "02" + constant.REG_ACTION + "01"
                + servo_num8.Text + "02" + constant.REG_ACTION + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }

            this.frmain.servosend(senddata);

            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
            this.Dispose();
        }

    }
}
